package com.chima.service.impl;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import com.chima.dao.JobstyleDao;
import com.chima.domain.Jobstyle;
import com.chima.domain.PageRequestBean;
import com.chima.domain.PageResponseBean;
import com.chima.service.JobstyleService;
public class JobstyleServiceImp  implements JobstyleService{
    private	JobstyleDao jobstyleDao ;
    
	public JobstyleDao getJobstyleDao() {
		return jobstyleDao;
	}


	public void setJobstyleDao(JobstyleDao jobstyleDao) {
		this.jobstyleDao = jobstyleDao;
	}


	public PageResponseBean findJobstyle(PageRequestBean pageRequestBean) {
		int firstResult =(pageRequestBean.getPage()-1)*pageRequestBean.getLimit();
		int maxResults =pageRequestBean.getLimit();
		int total = jobstyleDao.findByTotalCount();
		// 获取分页查询条件
		DetachedCriteria detachedCriteria = DetachedCriteria.forClass(Jobstyle.class);
//		DetachedCriteria detachedCriteria = pageRequestBean.getCriteria();// 不一定存在
		List<Jobstyle> jobstyles= jobstyleDao.findByCriteria(detachedCriteria, firstResult, maxResults);
		PageResponseBean pageResponseBean = new PageResponseBean();
		pageResponseBean.setRows(jobstyles);
		pageResponseBean.setTotal(total);
		return pageResponseBean;
	}
	public void saveJobstyle(Jobstyle jobstyle) {
		jobstyleDao.save(jobstyle);
	}
	public void updateJobstyle(Jobstyle jobstyle) {
		jobstyleDao.update(jobstyle);
	}
	public void deleteJobstyle(int id) {
	jobstyleDao.delete(id);
		
	}

}
